<template>
	<view class="box">
		<view class="bg">
			<image :src="user_info.avatar_bg" mode=""></image>
		</view>
		<view class="info">
			<view class="avatars">
				<u-avatar :src='user_info.avatar' shape="circle"></u-avatar>
			</view>
			<view class="nickname" style="margin-top: 10rpx;color: deeppink;font-size: 30rpx;">
				{{user_info.nickname}}
			</view>
			<view class="sex">
				{{sex}}
			</view>
			<view class="qianming" style="margin-bottom: 10rpx;">
			{{intruduce}}
			</view>
			<view class="school">
				{{school}}
			</view>

		</view>
	<view class="together">
		
		<view class="pice">
			<view :class="ischeck==item.id ? 'active':''" @click="isck(item.id)" v-for="item in lists" :key="item.id">
				{{item.text}}
			</view>
		</view>
		<view v-show="ischeck==0" class="homework" style="margin-top: 10rpx;">
			<view class="test" v-for="item in videolist">
				<other-pic :item="item"></other-pic>
			</view>
			<view v-if="nodata" style="margin-top: 30rpx;color: #F2E8CF;display: flex;justify-content: center;">
				<text>暂未发布</text>
			</view>
		</view>
		<view v-show="ischeck==1" class="homework" style="margin-top: 10rpx;">
			<view class="" v-for="item in 	zplist" :key="item._id">
				<workinfo :item="item"></workinfo>
			</view>
			<view v-if="nodata2" style="margin-top: 30rpx;color: #F2E8CF;display: flex;justify-content: center;">
				<text>暂未发布</text>
			</view>
		</view>
	</view>

	
	</view>
</template>

<script>
	import {
		methods
	} from '../../uni_modules/uview-ui/libs/mixin/mixin';
	const db = uniCloud.database()
	export default {
		data() {
			return {
				lists: [{
						text: '发布的视频',
						id: 0
					},

					{
						text: '发布的招聘',
						id: 1
					}
				],
				ischeck: 0,
				user_id: '',
				zplist: [],
				videolist: [],
				nodata: false,
				nodata2: false,
				//用户信息
				user_info:{}
			};

		},
		computed:{
			sex(){
				if(!this.user_info.gender){
					return '未知性别'
				}
				
				if(this.user_info.gender==0){
					return '未知性别'
				}
				if(this.user_info.gender==1){
					return '男'
				}
				if(this.user_info.gender==2){
					return "女"
				}
			},
			school(){
				if(this.user_info.school){
					return this.user_info.school
				}else{
					return "暂未填写学校"
				}
			},
			intruduce(){
				if(!this.user_info.introduce){
					return '这个人什么都没写'
				}else{
					return  this.user_info.introduce
				}
				
			}
		},
		onLoad(e) {
			this.user_id = e.id
			console.log(e)
			this.getuserinfo()
			this.getlistinfo()
			this.getvideo()
		},
		methods: {
			isck(e) {
				this.ischeck = e
			},
			async getlistinfo() {

				let reTemp = db.collection("recruitment").where({
					"user_id": this.user_id,

				}).field(
					'user_id,company_id,look_person,company_id,user_work,industry,criticism_title,study,money,work_impreance,position_desc,publish_date,company_name,company_nums'
				).getTemp()
				let userTemp = db.collection("uni-id-users").field('_id,nickname,avatar').getTemp()
				await db.collection(reTemp, userTemp).get().then(
					res => {
						console.log('广告', res)
						if (res.result.data.length == 0) {
							this.nodata2 = true
						}
						this.zplist = res.result.data
					})
			},

			async getvideo() {
				let reTemp = db.collection("video-articles").where({
					"user_id": this.user_id,

				}).field(
					'user_id,publish_date,avatar,content'
				).getTemp()

				let userTemp = db.collection("uni-id-users").field('_id,nickname,avatar').getTemp()
				await db.collection(reTemp, userTemp).orderBy('publish_date desc').get().then(
					res => {
						if (res.result.data.length == 0) {
							this.nodata = true
						}
						console.log('不是广告', res)
						this.videolist = res.result.data
					})
			},
			//获取个人信息
		async	getuserinfo(){
				await db.collection("uni-id-users").where({
					"_id":this.user_id
				}).field('avatar,avatar_bg,gender,nickname,introduce,school,brithday').get().then(res=>{
				this.user_info=res.result.data[0]
					console.log('人的',res)
				})
			}


		}
	}
</script>

<style lang="scss">
	.box {
		position: relative;
		.bg {
			image {
				width: 100%;
				height: 35vh;
			}
		}

		.info {
			height: 40vh;
			transform: translateY(-250rpx);
			background: linear-gradient(to top, #12275d 70%, rgba(255, 255, 255, 0.2));
			overflow: hidden;
			display: flex;
			flex-direction: column;
			align-items: center;
			color: #F2E8CF;
			font-size: 26rpx;
			.avatars {
				margin-top: 200rpx;
			}

			.nickname {}

			.sex {
				margin: 10rpx 0;
			}

		}
		.together{
				transform: translateY(-250rpx);
				position: absolute;
				width: 100%;
			.pice {
				display: flex;
				justify-content: space-around;
				align-items: center;
			
				view {
					color: #F2E8CF;
					margin-left: 50rpx;
					font-size: 30rpx;
			
					&.active {
						// transition: all 0.5s; 
						font-size: 40rpx;
					}
				}
			}
		}
		
	}
</style>
<style >
	page {
		background-color: #12275d;
	}
</style>